package com.zwps.biz.domain.service.impl;



import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.core.toolkit.StringUtils;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.zwps.biz.api.model.dto.mointordentify.AlarmBroacdCastVO;
import com.zwps.biz.api.model.vo.mointordentify.MonitDentifyListVO;
import com.zwps.biz.domain.service.AlarmBroadcastService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.zwps.biz.dal.db.object.AlarmBroadcastDO;
import com.zwps.biz.dal.db.dao.AlarmBroadcastDAO;

import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;
import java.util.*;


@Service
public class AlarmBroadcastServiceImpl extends ServiceImpl<AlarmBroadcastDAO, AlarmBroadcastDO> implements AlarmBroadcastService {

    @Autowired
    AlarmBroadcastDAO broadcastDAO;
    @Override
    public IPage<AlarmBroadcastDO> getAlarmBroadCastList(
            String startTime,
            String endTime,
            Integer pageNum,
            Integer pageSize) {
        return new Page<>();
        /*if (StringUtils.isBlank(startTime) && StringUtils.isBlank(endTime)) {
            LocalDateTime endDate = LocalDateTime.now();
            // 查询最近一个月数据（当前时间往前推30天）
            LocalDateTime startDate = endDate.minusDays(30);

            startTime = startDate.format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"));
            endTime = endDate.format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"));
        }
        //分页
        if (pageNum ==null ||pageNum <= 0) {
           pageNum=1;
        }
        if (Objects.isNull(pageSize) || pageSize <= 0) {
            pageSize=10;
        }
        Page<AlarmBroadcastDO> page = new Page<AlarmBroadcastDO>(pageNum,pageSize);
        LambdaQueryWrapper<AlarmBroadcastDO> wrapper = new LambdaQueryWrapper<AlarmBroadcastDO>()
                .between(AlarmBroadcastDO::getEventTime, startTime, endTime)
                .orderByDesc(AlarmBroadcastDO::getEventTime);
        IPage<AlarmBroadcastDO> resultPage = broadcastDAO.selectPage(page,wrapper);
        for (AlarmBroadcastDO record : resultPage.getRecords()) {
            List<String> urlList = Arrays.asList(record.getImgsUrl().split(","));
            record.setImgsUrlList(urlList);
        }
        return resultPage;*/
    }
}
